﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using IODataAccess;
using IOEntity;
namespace IOBusiness
{
    public class clsBSTestimonials
    {
        clsDATestimonials obj = new clsDATestimonials();
        public clsTestimonials GetById(int id)
        {
            try
            {
                return obj.GetById(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public clsTestimonials GetByShort()
        {
            try
            {
                clsTestimonials obj = new clsTestimonials();
                obj= this.obj.GetAll()[0];
                obj.NoiDung = obj.NoiDung.Substring(0, obj.NoiDung.Length > 300 ? 300 : obj.NoiDung.Length);
                return obj;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsTestimonials> GetAll()
        {
            try
            {
                return obj.GetAll();
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsTestimonials> GetAll(int id)
        {
            try
            {
                List<clsTestimonials> obj= new List<clsTestimonials>();
                obj = this.obj.GetAll();
                foreach (clsTestimonials item in obj)
                {

                    if (item.Id == id)
                    {
                        obj.Remove(item);
                        break;
                    }
                }
                return obj;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public int Insert(clsTestimonials obj)
        {
            try
            {
                return this.obj.Insert(obj);
            }
            catch (Exception)
            {

                throw;
            }
            
        }
        public void Update(clsTestimonials obj)
        {
            try
            {
                this.obj.Update(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Delete(int id)
        {
            try
            {
                obj.Delete(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
